<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<%@ page import="java.io.*" %>
<%@ page import="interface_layer.*" %>
<%@ page import="database_layer.*" %>
<%@ page errorPage="exceptionPage.jsp" %>
<%-- 
	This JSP is our error page. Instead of showing 404's or 503's, we decided to
	use our style, and present printed errors, depends on the error sent.
 --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255"/>
<link href="css/templatemo_style.css" rel="stylesheet" type="text/css" />
<title>Error page</title>
</head>
<body>
<jsp:include page="header_part_1.html"/>
            <div id="templatemo_menu">
                <ul>
                    <li><a href="index.jsp">Home</a></li>
                    <li><a href="about.jsp">About Us</a></li>
<%
                    	String username = (String) session.getAttribute("username");
                        if (null != username)
                        {
%>
                            <li><a href="userPage.jsp">Your profile</a></li>
                    		<li><a href="allCourses.jsp">Courses</a></li>
                    		<li><a href="allUsers.jsp">Users</a></li>
<%
                        }
%>
                </ul>    	
            </div> <!-- end of templatemo_menu -->
<jsp:include page="header_part_2.html"/>
<div id="content">
<b>You've encountered an error...</b><br/>
<%
	String error = request.getParameter("error");
	if (null == error)
	{
%>
		<i>This is embarrassing, we're not sure what the error is...</i>
<%
	}
	else
	{
		int numericError = Integer.parseInt(error);
		String errorMessage = null;
		switch(numericError)
		{
			case Common.ENTRY_EXISTS:
				errorMessage = "One of the values you wished to be added already exists!";
				break;
			case Common.ENTRY_DOESNT_EXIST:
				errorMessage = "One of the values you've inserted / requested doesn't exist!";
				break;
			case Common.ILLEGAL_OPERATION:
				errorMessage = "You're performed an illegal operation!";
				break;
			case Common.BAD_PARAMETERS:
				errorMessage = "One of the your input / requested parameters is invalid!";
				break;
			case Common.OVERLAPPING_ENTRIES:
				errorMessage = "Some of the required sessions overlap, operation denied!";
				break;
			case Common.UNAUTHORIZED_OPERATION:
				errorMessage = "You are not authorized to perform this action, it may require Student or Admin priviliges!";
				break;
			case Common.INTERNAL_DB_ERROR:
				errorMessage = "The DB has encountered an unexcepted error, please try again in a few seconds!";
				break;
			case Common.USER_CONNECTED:
				errorMessage = "The user is currently connected, you're not allowed to remove him. Please wait for him to logout!";
				break;
			case Common.INTERNAL_ERROR:
				errorMessage = "The web service has encountered an internal error (not DB related), please contact the administrators";
				break;
			default:
				errorMessage = "This is embarrassing, we're not sure what the error is...";
				break;
		}
%>
	<i><%= errorMessage %></i>
<%
	}
%>
</div>
<jsp:include page="sidebar.jsp"/>
<jsp:include page="footer.html"/>
</body>
</html>